import M from "./m";
import Single from './single'
class LibMedia extends M {
  componentName = 'libMedia';
  medias: Array<Single> = [];
  materia_form() {
    return [{
      name: '素材',
      key: 'mediaGroup',
      rules: () => {
        return this.media_restriction;
      },
      // 至少需要1个素材
      min: 1,
      max: 15,
      values: []
    }]
  }
  setSrc(options: { keyFrameImageUrl?: string, media_id: string, media_url: string, meta_type: string, cover_id: string, number: number }) {
    const media = this.medias[options.number];
    media.setSrc(options);
  }
  mediaMap(_function: Function): Array<any> {
    return this.medias.map(media => _function(media));
  }

  empty() {
    this.medias = [];
  }
}

export default LibMedia;
